var cm_orgcheckself = new Ext.grid.ColumnModel([
	new Ext.grid.RowNumberer({header : '序号', width : 40, dataIndex: 'id'}),
    {id: 'year',header: "考核年度", width: 120, dataIndex: 'year'},
    {id: 'type',header: "指标类型", width: 80, sortable: true, dataIndex: 'type', renderer : fun_getGoalType},
	{id: 'detailId',header: "指标细则", width: 100, sortable: true, dataIndex: 'detailId'},
	{id: 'orgId',header: "被考核部门", width: 100, hidden: true, dataIndex: 'orgId',
		renderer : function(v) {
			var ret = '';
			var size = ds_org_select.getCount();
			for (var i = 0; i < size; i++) {
				var record = ds_org_select.getAt(i);
				var id = record.get('id');
				if (id == v) {
					ret = record.get('name');
					break;
				}
			}
			return (ret == '' || ret == null) ? v : ret;
		}},
	{id: 'memo',header: "备注", width: 100, hidden: true, dataIndex: 'memo'},
	{id: 'checkOrgId',header: "考核责任单位", width: 100, sortable: true, dataIndex: 'checkOrgId',
		renderer : function(v) {
			var ret = '';
			var size = ds_org_select.getCount();
			for (var i = 0; i < size; i++) {
				var record = ds_org_select.getAt(i);
				var id = record.get('id');
				if (id == v) {
					ret = record.get('name');
					break;
				}
			}
			return (ret == '' || ret == null) ? v : ret;
		}},
	{id: 'checkResult',header: "考核意见", width: 100, hidden: true, dataIndex: 'checkResult'},
    {id: 'score',header: "考核得分", width: 100, sortable: true, dataIndex: 'score'},
	{id: 'selfScore',header: "自评分", width: 100, sortable: true, dataIndex: 'selfScore',
		editor : new Ext.form.NumberField({
			allowBlank : true,
			maxLength : 100
		})},
	{id: 'goStatus',header: "该考核指标的进展状态", width: 150, sortable: true, dataIndex: 'goStatus',
		editor : new Ext.form.ComboBox({
			fieldLabel : '该考核指标的进展状态',
			triggerAction : 'all',
			loadingText : '加载中...',
			emptyText : '请选择进展状态',
			mode : 'local',
			valueField : 'value',
			displayField : 'value',
			store : new  Ext.data.SimpleStore({
				data: data_go_status,
				expandData: true,
				fields : ['value']
			}),
			allowBlank : true
		})},
	{id: 'finishResult',header: "该考核指标的完成情况", width: 160, sortable: true, dataIndex: 'finishResult',
		editor : new Ext.form.TextField({
			allowBlank : true,
			maxLength : 100
		})}

]);
var ds_orgcheckself = new Ext.data.Store({
	proxy : new Ext.data.HttpProxy({
		url : '/supervise/biz/orgcheck/findOrgCheckSelf.action'
	}),
	reader : new Ext.data.JsonReader({
		root : 'root',
		successProperty :'success'
	}, [{
			name : 'id',
			type : 'int'
		}, {
			name : 'detailId',
			type : 'int'
		}, {
			name : 'orgId',
			type : 'int'
		},{
			name : 'goStatus',
			type : 'string'
		},{
			name : 'finishResult',
			type : 'string'
		}, {
			name : 'score',
			type : 'float'
		}, {
			name : 'selfScore',
			type : 'float'
		},{
			name : 'checkOrgId',
			type : 'int'
		},{
			name : 'memo',
			type : 'string'
		},{
			name : 'checkOrgId',
			type : 'int'
		},{
			name : 'checkResult',
			type : 'string'
		},{
		name : 'year',
		type : 'int'
	},{
			name : 'type',
			type : 'string'
		}])
});
var grid_orgcheckself = new Ext.grid.EditorGridPanel({
			title : '请填报（自评分,进展状态,完成情况）',
			iconCls : 'icon-grid',
			loadMask : {
				msg : '数据加载中...'
			},
			viewConfig : {
				forceFit : true
			},
			region : 'center',
			cm : cm_orgcheckself,
			sm : new Ext.grid.RowSelectionModel({
						singleSelect : true
					}),
			store : ds_orgcheckself,
			autoExpandColumn : 'goStatus',
//			tbar : [btn_add_orgcheck, '-', btn_edit_orgcheck, '-', btn_del_orgcheck, '-', btn_search_orgcheck],
			bbar : new Ext.PagingToolbar({
						pageSize : 20,
						store : ds_orgcheckself,
						displayInfo : false,
						displayMsg : '第 {0} - {1} 条  共 {2} 条',
						refreshText : "刷新",
						emptyMsg : "没有记录"
					}),
			// 检测至少选择一个
			checkOne : function() {
				var selections = this.getSelectionModel().getSelections();
				if (selections.length == 0) {
					Ext.MessageBox.alert("提示", "请选择一条的记录！");
					return false;
				} else if (selections.length != 1) {
					Ext.MessageBox.alert("提示", "不能选择多行！");
					return false;
				}
				return true;
			},

			// 检测必须选择一个
			checkMany : function() {
				var selections = this.getSelectionModel().getSelections();
				if (selections.length == 0) {
					Ext.MessageBox.alert("提示", "请至少选择一条的记录！");
					return false;
				}
				return true;
			},
			listeners : {
				'afteredit' : function(e) {
					Ext.Ajax.request({
						url : '/supervise/biz/orgcheck/updateOrgCheck.action',
						params : {
							fieldName : e.field,
							fieldValue : e.value,
							id : e.record.data.id
						},
						success : function() {
							// alert("数据修改成功！");
						},
						failure : function() {
							Ext.Msg.show({
								title : '错误提示',
								msg : '修改数据发生错误,操作将被回滚!',
								fn : function() {
									e.record.set(e.field, e.originalValue);
								},
								buttons : Ext.Msg.OK,
								icon : Ext.Msg.ERROR
							});
						}
					});
				}
			}

		});
var qpanel_orgcheckself = new Ext.Panel({
//	title : '<h3 style="color:Green">请输入查询条件</h3>',
	height : 100,
	region : "north",
	baseCls:"x-plain",
	style:"padding:5px",
	layout:"column",
	items:[{
		columnWidth:0.6,
		layout:"form",
		frame : true,
		baseCls : 'x-plain',
		items : [new Ext.FormPanel({
			id: 'form_query_orgcheckself',
			labelAlign : 'right',
			border : false,
			baseCls : 'x-plain',
			bodyStyle : 'padding:5px 5px 0',
			defaults : {
				anchor : '90%',
				width : 240,
				msgTarget : 'side' // 验证信息显示右边
			},
			defaultType : 'textfield',
			items:[{
					xtype : 'combo',
					fieldLabel : '考核年度',
					hiddenName : 'year',
					valueField : 'value',
					displayField : 'text',
					value: check_year,
					mode : 'local',
					store : ds_year_select,
					value : select_year,
					selectOnFocus : true,
					editable : false,
					allowBlank : false,
					typeAhead : true,
					readOnly : true,
					triggerAction : 'all',
					loadingText : '加载中...',
					emptyText : '请选择考核年度'
				}, {
					fieldLabel : '考核内容',
					name : 'content'
				}],
			buttonAlign : 'center',
			minButtonWidth : 60,
			buttons : [{
						text : '查询',
						handler : function(btn) {
							var frm = btn.ownerCt.ownerCt.getForm();
							ds_orgcheckself.load({params : {
								start : 0,limit : 20,
								year : frm.findField('year').getValue(),
								content : frm.findField('content').getValue()
							}});}
					},{
						text : '重置',
						handler : function() { 
							this.ownerCt.ownerCt.getForm().reset();
						}
					}]
		})]
	}]
});

var query_orgcheckself =  new Ext.Panel({
	frame : false,
	region : 'center',
	labelWidth : 65,
	title : '考核指标填报',
	labelPad : 45,
	buttonAlign : 'center',
	layout : 'border',
	items : [qpanel_orgcheckself, grid_orgcheckself]
});	
var p_orgcheckself = {
	id : 'orgcheckself-panel',
	border : false,
	layout : 'border',
	items : [query_orgcheckself]
};
  
